package com.srcptit.java.training.dungvv.btvn1;

import java.util.Scanner;

public class B2_M2_solan {
	public static void main(String []args){
		int a[], b[];
		int n;
		Scanner sc = new Scanner(System.in);
		System.out.println("Moi nhap vao so phan tu cua day");
		n = sc.nextInt();
		a = new int[n];
		b = new int[n];
		for(int i = 0; i < n; i++){	
			System.out.println("Nhap a["+i+"] = ");   //a[] mang cac phan tu
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) //khoi tao mang b[] dung de dem so lan xuat hien
			b[i] = 1;
		for(int i = 0; i<n-1; i++)
			for(int j = i+1; j<n; j++){
				if(b[j]==0) continue;		//bo qua cac phan tu a[i] da co tu truoc
				if(a[i]==a[j]){				
					b[i]++;
					b[j]=0;
				}
			}
		for(int i = 0; i < n; i++)
			if (b[i] != 0){
				System.out.println(a[i]+"xuat hien "+b[i]+"lan");
			}
	}
}
